package com.lin.controller.Client;

import com.lin.pojo.Shopping;
import com.lin.response.CommonResp;
import com.lin.service.ShoppingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/client/shopping")
public class ShoppingController {
    @Autowired
    private ShoppingService shoppingService;

    @GetMapping("/select")
    public CommonResp page(@RequestParam Integer pageNum,@RequestParam Integer pageSize,@RequestParam String username,@RequestParam String dish){
        return shoppingService.page(pageNum,pageSize,username,dish);
    }
    @PostMapping("/change")
    public CommonResp changeCount(@RequestBody Shopping shopping){
        return shoppingService.changeCount(shopping);
    }

    @GetMapping("/pay")
    public CommonResp pay(@RequestParam Integer tableid,
                          @RequestParam String username,
                          @RequestParam String detail,
                          @RequestParam Integer totalPrice){
        return shoppingService.pay(tableid,username,detail,totalPrice);
    }

    @PostMapping("/remove")
    public CommonResp remove(@RequestBody Shopping shopping){
        System.out.println("shopping" + shopping);
        return shoppingService.remove(shopping);
    }
}
